home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209b.zip / octave-2.09 / DLFCN.ZIP / dlfcn / octave / oct-iostrm.h < prev    next >
C/C++ Source or Header  |  1997-08-20  |  3KB  |  140 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if !defined (octave_octave_iostream_h)
  24. #define octave_octave_iostream_h 1
  25.  
  26. #include "oct-stream.h"
  27.  
  28. class istream;
  29. class ostream;
  30.  
  31. class
  32. octave_base_iostream : public octave_base_stream
  33. {
  34. public:
  35.  
  36.   octave_base_iostream (const string& n = string (),
  37.             ios::openmode md = ios::in|ios::out,
  38.             oct_mach_info::float_format flt_fmt =
  39.             oct_mach_info::native)
  40.     : octave_base_stream (md, flt_fmt), nm (n) { }
  41.  
  42.   ~octave_base_iostream (void) { }
  43.  
  44.   // Position a stream at OFFSET relative to ORIGIN.
  45.  
  46.   int seek (streamoff offset, ios::seek_dir origin);
  47.  
  48.   // Return current stream position.
  49.  
  50.   long tell (void) const;
  51.  
  52.   // Return non-zero if EOF has been reached on this stream.
  53.  
  54.   bool eof (void) const;
  55.  
  56.   // The name of the file.
  57.  
  58.   string name (void);
  59.  
  60. protected:
  61.  
  62.   void invalid_operation (void) const;
  63.  
  64. private:
  65.  
  66.   string nm;
  67.  
  68.   virtual const char *stream_type (void) const = 0;
  69.  
  70.   // No copying!
  71.  
  72.   octave_base_iostream (const octave_base_iostream&);
  73.  
  74.   octave_base_iostream& operator = (const octave_base_iostream&);
  75. };
  76.  
  77. class
  78. octave_istream : public octave_base_iostream
  79. {
  80. public:
  81.  
  82.   octave_istream (istream *arg = 0, const string& nm = string ())
  83.     : octave_base_iostream (nm, ios::in, oct_mach_info::native),
  84.       is (arg) { }
  85.  
  86.   ~octave_istream (void) { }
  87.  
  88.   istream *input_stream (void) { return is; }
  89.  
  90.   ostream *output_stream (void) { return 0; }
  91.  
  92. private:
  93.  
  94.   istream *is;
  95.  
  96.   const char *stream_type (void) const { return "octave_istream"; }
  97.  
  98.   // No copying!
  99.  
  100.   octave_istream (const octave_istream&);
  101.  
  102.   octave_istream& operator = (const octave_istream&);
  103. };
  104.  
  105. class
  106. octave_ostream : public octave_base_iostream
  107. {
  108. public:
  109.  
  110.   octave_ostream (ostream *arg, const string& nm = string ())
  111.     : octave_base_iostream (nm, ios::out, oct_mach_info::native),
  112.       os (arg) { }
  113.  
  114.   ~octave_ostream (void) { }
  115.  
  116.   istream *input_stream (void) { return 0; }
  117.  
  118.   ostream *output_stream (void) { return os; }
  119.  
  120. private:
  121.  
  122.   ostream *os;
  123.  
  124.   const char *stream_type (void) const { return "octave_ostream"; }
  125.  
  126.   // No copying!
  127.  
  128.   octave_ostream (const octave_ostream&);
  129.  
  130.   octave_ostream& operator = (const octave_ostream&);
  131. };
  132.  
  133. #endif
  134.  
  135. /*
  136. ;;; Local Variables: ***
  137. ;;; mode: C++ ***
  138. ;;; End: ***
  139. */
  140.